<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['namespace' => 'Api'], function () {
    Route::get('test','TestController@index');
    Route::get('test/users','TestController@users');
    //Route::post('test/upload','TestController@upload');
    Route::get('pay','TestController@pay');

    //小程序根据code获取openid和session_key
    Route::post('wechatmini/get_mini_session','WechatMiniController@get_mini_session')->name('api.wechatmini.get_mini_session');

    //获取省市区
    Route::get('areas','AreasController@index')->name('api.areas.index');

    //保存用户信息
    Route::post('user/store','UsersController@store')->name('api.user.store');
    //绑定手机号-发送验证码
    Route::post('user/send_verification_code','UsersController@send_verification_code')->name('api.user.send_verification_code');
    //绑定手机号-提交绑定
    Route::post('user/bind_telephone','UsersController@bind_telephone')->name('api.user.bind_telephone');
    //根据用户openid获取用户信息
    Route::post('user/info','UsersController@info')->name('api.user.info');
    //检测用户是否绑定手机号码
    Route::post('user/check_telephone','UsersController@check_telephone')->name('api.user.check_telephone');

    //我收藏的书单
    Route::get('user/my_collect_book_lists','UsersController@getMyCollectBookLists')->name('api.user.my_collect_book_lists');
    //会员时长明细
    Route::get('user/vip_time_records','UsersController@getVipTimeRecords')->name('api.user.vip_time_records');
    //获取会员卡列表
    Route::get('user/user_vip_types','UsersController@getVipTypes')->name('api.user.user_vip_types');
    //我的书评
    Route::get('user/my_comments','UsersController@my_comments')->name('api.user.my_comments');
    //我邀请的好友
    Route::get('user/my_invite_users','UsersController@myInviteUsers')->name('api.user.my_invite_users');
    //获取分享者用户信息
    Route::get('user/share_user_info','UsersController@share_user_info')->name('api.user.share_user_info');
    //用户中心
    Route::get('user/{user}','UsersController@show')->name('api.user.show');
    //提交想要的书籍
    Route::post('user/want/books','UsersController@want_books')->name('api.user.want_books');


    //添加收货地址
    Route::post('user_address/store','UserAddressesController@store')->name('api.user_address.store');
    //修改收货地址
    Route::put('user_address/{user_address}','UserAddressesController@update')->name('api.user_address.update');
    //查看收货地址
    Route::get('user_address/{user_address}','UserAddressesController@show')->name('api.user_address.show');
    //分页获取收货地址
    Route::get('user_addresses','UserAddressesController@index')->name('api.user_address.index');
    //删除收货地址
    Route::delete('user_address/{user_address}','UserAddressesController@destroy')->name('api.user_address.destroy');


    //获取图书分类
    Route::get('categories','CategoriesController@index')->name('api.categories.index');
    //获取图书二级分类
    Route::get('second/categories','CategoriesController@secondCategories')->name('api.categories.second');

    //图书列表
    Route::get('books','BooksController@index')->name('api.books.index');
    //豆瓣高分/小编力荐/最新出版
    Route::get('books/list','BooksController@getList')->name('api.books.list');

    Route::post('books/import','BooksController@import')->name('api.books.import');
    //搜索页面
    Route::get('books/search_page','BooksController@searchPage')->name('api.books.search_page');
    //搜索
    Route::get('books/search','BooksController@search')->name('api.books.search');
    //图书详情
    Route::get('books/{book}','BooksController@show')->name('api.books.show');
    //图书详情中的评论列表
    Route::get('books/comments/{book}','BooksController@comments')->name('api.books.comments');
    //点赞评论
    Route::post('books/comments/good','BooksController@storeGood')->name('api.books.comments.good.store');
    //取消点赞评论
    Route::delete('books/comments/good','BooksController@destroyGood')->name('api.books.comments.good.destroy');


    //加入书架
    Route::post('user_carts', 'UserCartsController@store')->name('api.user_cart.store');
    //书架
    Route::get('user_carts', 'UserCartsController@index')->name('api.user_cart.index');
    //移除书架
    Route::post('user_carts/delete', 'UserCartsController@delete')->name('api.user_cart.delete');

    //模拟已收货
    Route::get('orders/test', 'OrdersController@test')->name('api.orders.test');
    //检查下单
    Route::post('orders/check', 'OrdersController@check')->name('api.orders.check');
    //下单
    Route::post('orders', 'OrdersController@store')->name('api.orders.store');
    //订单列表
    Route::get('orders', 'OrdersController@index')->name('api.orders.index');
    //查看物流信息
    Route::get('orders/express_info/{order}', 'OrdersController@express_info')->name('api.orders.express_info');
    //借阅历史
    Route::get('orders/histroy', 'OrdersController@histroy')->name('api.orders.histroy');
    //评价
    Route::post('orders/comment', 'OrdersController@comment')->name('api.orders.comment');
    //预约取件
    Route::post('orders/back_order', 'OrdersController@back_order')->name('api.orders.back_order');
    //预约取件后发送模板消息
    Route::post('orders/back_order/send_template_message', 'OrdersController@back_order_send_template_message')->name('api.orders.back_order.send_template_message');

    Route::post('orders/cancel_back_order', 'OrdersController@cancel_back_order')->name('api.orders.cancel_back_order');
    //归还详情
    Route::get('orders/back_order_detail/{order}', 'OrdersController@back_order_detail')->name('api.orders.back_order_detail');

    //首界面
    Route::get('homepage/index','HomepageController@index')->name('api.homepage.index');
    Route::get('homepage/recommend','HomepageController@recommend')->name('api.homepage.recommend');

    //书单分类
    Route::get('book_list/categories','BookListsController@categories')->name('api.book_list.categories');
    //书单列表
    Route::get('book_list/index','BookListsController@index')->name('api.book_list.index');
    //书单详情
    Route::get('book_list/{book_list}','BookListsController@show')->name('api.book_list.show');
    //收藏书单/取消收藏书单
    Route::post('book_list/collect','BookListsController@collect')->name('api.book_list.collect');


    //微信 - 支付会员
    Route::post('payment/wechat/pay_user_vip', 'PaymentController@payUserVipByWechat')->name('api.payment.wechat.pay_user_vip');
    //微信 - 会员支付回调
    Route::post('payment/wechat/notify', 'PaymentController@wechatNotify')->name('api.payment.wechat.notify');

});

Route::group(['namespace' => 'Admin'], function () {
    Route::get('admin/first/categories','CategoriesController@fisrtIndex')->name('api.admin.first.categories.index');
    Route::get('admin/second/categories','CategoriesController@secondIndex')->name('api.admin.second.categories.index');
    Route::get('admin/search/books','BooksController@search')->name('api.admin.search.books');
    Route::get('admin/users','UsersController@index')->name('api.admin.users.index');
});
